<?php require_once '../ptnhuan-web1/data/users.php'; ?>
<form method="POST">
    username: <input type="text" name="username" placeholder="Username">
    password: <input type="password" name="password" placeholder="password" >
    <input type="submit" name="submit" value="Dang Nhap">
</form>
<?php if (isset($_POST['submit'])): ?>
    <?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    $DNok = FALSE;
    $index = -1;
//vong for ktra user:
    for ($i = 0; $i < count($users); $i++) {
        if ((strcmp($users[$i]['username'], $username) == 0) && (strcmp($users[$i]['password'], $password) == 0)) {
            $DNok = TRUE;
            $index = $i;
        }
    }
//lỗi
    if ($DNok) {
        //Đăng nhập thành công
        header("Location: http://localhost:82/dttan-web1/review_film.php?uid=" . $users[$index]['id']);
    } else {
        echo 'Đăng nhập thất bại';
    }
    ?>
<?php endif; ?>

